/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package metro.jme.lottery.graphics.screens;

import java.util.Hashtable;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import metro.jme.lottery.main.LotteryMIDlet;

/**
 *
 * @author pierre
 */
public class TrackSelecter extends Form implements CommandListener {

	private static String CURRENT_TRACK = "cotton";
	private static final String[] TRACK_LIST = {"cotton", "killbill",
												"mission", "mohicans", "pinkpanther",
												"pirates", "starwars", "surfing"};
	private Command m_backCmd;
	private Displayable previousScreen;
	private LotteryMIDlet m_MIDlet;
	private ChoiceGroup m_choiceGroup;
	
	private static Hashtable songs;
	
	public TrackSelecter(LotteryMIDlet m, Displayable d) {
		super("Select a track");
		previousScreen = d;
		m_MIDlet = m;
		
		m_backCmd = new Command("Back", Command.BACK, 1);
		this.addCommand(m_backCmd);
		
		songs = new Hashtable();
		songs.put("cotton", "Cotton eyed joe");
		songs.put("killbill", "Kill Bill");
		songs.put("mission", "Mission Impossible Them");
		songs.put("mohicans", "Last of Mohicans OST");
		songs.put("pinkpanther", "Pink Panther");
		songs.put("pirates", "Pirates of the caribean OST");
		songs.put("starwars", "Star Wars Theme");
		songs.put("surfing", "Surfing with the alien");
		init();
	}

	private void init() {
		m_choiceGroup  = new ChoiceGroup("Select a track", ChoiceGroup.EXCLUSIVE, TRACK_LIST, null);
		this.append(m_choiceGroup);
	}

	public void commandAction(Command cmnd, Displayable dsplbl) {
		if(cmnd == m_backCmd) {
			CURRENT_TRACK = m_choiceGroup.getString(m_choiceGroup.getSelectedIndex());
			m_MIDlet.displayNewScreen(previousScreen);
		}
	}

	public static String getCURRENT_TRACK() {
		return CURRENT_TRACK;
	}

	public static void setCURRENT_TRACK(String CURRENT_TRACK) {
		TrackSelecter.CURRENT_TRACK = CURRENT_TRACK;
	}
	
	public static String getCurrentTrackName() {
		if (songs != null) {
			return (String)songs.get(CURRENT_TRACK);
		} else {
			return "Cotton eyed joe";
		}
	}
	
}
